package force;

import backbone.IForceable;
import main.Simulation;

/**
 * Represents a viscous global force of the
 * form F = -kv.
 * @author Paul
 * @author Lance
 */
public class Viscosity extends GlobalForce {
    private static final String NAME = "Viscosity";
    /**
     * 
     * @param magnitude
     */
    public Viscosity(double magnitude) {
        super(magnitude, NAME);
    }

    @Override
    public void update(Simulation canvas, double dt) {
        for (IForceable forceable : getForceables()) {
            Force velocity = new Force(forceable.getVelocity());
            velocity.negate();
            velocity.scale(getMagnitude());
            forceable.applyForce(velocity);
        }
    }
}
